package com.cci.kangdao.wechatOrder.dao;

import com.cci.kangdao.wechatOrder.model.WeChatSmsLinkTokenT;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mybatis.spring.annotation.MapperScan;

/**
 * @description:
 * @author: zyf
 * @create: 2021-03-28
 */
@MapperScan
public interface WeChatSmsLinkTokenTDao {

    int insert(WeChatSmsLinkTokenT linkTokenT);

    @Select("select * from WeChatSmsLinkToken_T where ID = #{id} and Flag =0")
    WeChatSmsLinkTokenT selectById(@Param("id")Long id);

    @Select("select * from WeChatSmsLinkToken_T where OrderId = #{orderId} and Flag =0")
    WeChatSmsLinkTokenT selectByOrderId(@Param("orderId")Long orderId);

    @Select("select * from WeChatSmsLinkToken_T where CrmOrderNo = #{crmOrderNo} and Flag =0")
    WeChatSmsLinkTokenT selectByCrmOrderNo(@Param("crmOrderNo")Long crmOrderNo);

    @Select("select * from WeChatSmsLinkToken_T where Token = #{token}")
    WeChatSmsLinkTokenT selectByToken(@Param("token")String token);

    int updateFlagByToken(WeChatSmsLinkTokenT linkTokenT);
    @Update("update WeChatSmsLinkToken_T set flag=#{flag} where BindId = #{id} and Flag =0")
    int updateFlagByBindId(@Param("id")Long id,@Param("flag")Integer flag);

    @Select("select * from WeChatSmsLinkToken_T where  BindId = #{id} and Flag = #{flag}")
    WeChatSmsLinkTokenT selectByTokenAndFlagAndId(@Param("id")Long id,@Param("flag")Integer flag);

}
